<template>
  <div>
    <van-cell v-if="type === 0" :title="artcleInfo.title" :label="label" />
    <van-cell v-else-if="type === 1" :title="artcleInfo.title" :label="label">
      <van-image width="100" height="100" :src="artcleInfo.cover?.images[0]" />
    </van-cell>
    <van-cell v-else :title="artcleInfo.title">
      <template #label>
        <van-image v-for="(obj, index) in artcleInfo.cover?.images" :key="index" width="100" height="100" :src="obj" />
        <span>{{ label }}</span>
      </template>
    </van-cell>
  </div>
</template>

<script>
import dayjs from '@/utils/dayjs'
export default {
  props: {
    //默认值：如果基本数据类型可以直接给
    //复杂数据类型，以函数的返回值给他
    artcleInfo: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {
    type() {
      return this.artcleInfo.cover?.type
    },
    label() {
      const { aut_name, pubdate, comm_count } = this.artcleInfo
      return `${aut_name} ${comm_count}评论 ${dayjs(pubdate).fromNow()}`
    }
  }
}
</script>

<style>

</style>
